package generic;

/**
 * Created by Terry
 * Description:
 * User: GAOBO
 * Date: 2021-07-27
 * Time: 9:28
 */
class Stack<T> {
    public T[] objects;
    public int top;

    public Stack() {
        this.objects = (T[])new Object[10];
    }

    public void push(T obj) {
        objects[this.top++] = obj;
    }

    public T get() {
        return objects[this.top-1];
    }
}
public class TestDemo {
    public static void main2(String[] args) {
        Stack stack = new Stack();
        stack.push(1);
        stack.push(2);
        stack.push("gaobo");
    }
    public static void main1(String[] args) {
        Stack<Integer> stack = new Stack<>();
        stack.push(1);
        stack.push(2);
        //stack.push("gaobo");
        int ret = stack.get();
        System.out.println(ret);

        Stack<Character> stack2 = new Stack<>();

        System.out.println(stack);
        System.out.println(stack2);

    }
   /* public static void main(String[] args) {
        Stack stack = new Stack();
        stack.push(1);
        stack.push(2);
        stack.push("gaobo");
        String str = (String)stack.get();
    }*/
}
